package lambdasinaction.chap3;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class StreamTest {

    public static void main(String[] args) {
        List<Long> ids = Arrays.asList(1L, 2L, 3L, 4L, 4L);

        Long[] idArrays = ids.stream().map(i -> i * i).toArray(Long[]::new);

        List<Long> collect = Arrays.stream(idArrays).collect(Collectors.toList());

        Map<Long, Long> map = Arrays.stream(idArrays).collect(Collectors.toMap(Function.identity(), i -> i * i, (s, a) -> a));

        System.out.println(Arrays.toString(idArrays));

        System.out.println(collect);

        System.out.println(map);
    }

}
